package hys.wwsa.modules.info.controller;

import java.util.Arrays;
import java.util.Map;

import hys.wwsa.modules.info.entity.CountrysideEntity;
import hys.wwsa.modules.info.service.CountrysideService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import hys.wwsa.common.utils.PageUtils;
import hys.wwsa.common.utils.R;



/**
 * 
 *
 * @author hys
 * @email 2439206957@qq.com
 * @date 2024-02-26 15:21:50
 */
@RestController
@RequestMapping("info/countryside")
public class CountrysideController {
    @Autowired
    private CountrysideService countrysideService;

    /**
     * 列表
     */
    @RequestMapping("/list")
//    @RequiresPermissions("info:countryside:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = countrysideService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{countrysideId}")
//    @RequiresPermissions("info:countryside:info")
    public R info(@PathVariable("countrysideId") Integer countrysideId){
		CountrysideEntity countryside = countrysideService.getById(countrysideId);

        return R.ok().put("countryside", countryside);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("info:countryside:save")
    public R save(@RequestBody CountrysideEntity countryside){
		countrysideService.save(countryside);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("info:countryside:update")
    public R update(@RequestBody CountrysideEntity countryside){
		countrysideService.updateById(countryside);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("info:countryside:delete")
    public R delete(@RequestBody Integer[] countrysideIds){
		countrysideService.removeByIds(Arrays.asList(countrysideIds));

        return R.ok();
    }

}
